//
//  WmcPhotoLayout.swift
//  YPWatermarkCamera
//
//  Created by Json on 2023/8/2.
//

import UIKit
import HandyJSON

class WmcPhotoLayout: WmcBaseModel {
    
    enum Columns: Int, CaseIterable, HandyJSONEnum {
        case one = 1
        case two
        case three
        case four
        
        struct Info {
            /// 默认照片数量
            var defaultNum: Int
            /// 标题
            var title: String
            /// 行数
            var rows: Int
        }
        
        var info: Info {
            switch self {
            case .one:
                return Info(defaultNum: 10, title: "单列", rows: 2)
            case .two:
                return Info(defaultNum: 10, title: "双列", rows: 1)
            case .three:
                return Info(defaultNum: 9, title: "九宫格", rows: 3)
            case .four:
                return Info(defaultNum: 12, title: "四列", rows: 3)
            }
        }
        /// 照片数量
        var photoNum: Int {
            if let num: Int = WmcUserdefault.object(forKey: .State.CombinePhoto.layoutPhotoNum, associateValue: "\(self.rawValue)") {
                return num
            }
            return info.defaultNum
        }
    }
    /// 列数
    var columns: Columns = .one
    /// 是否选中
    var isSelected: Bool = false
    /// item的宽度
    var itemW: CGFloat = 0.0
    /// 图片张数
    var photoNum: Int = 0
    
    required init() {
        super.init()
    }
    
    
    init(columns: Columns) {
        self.columns = columns
        super.init()
    }
}
